DRAKHYSYS STORY MAKER — V4.8.8.106
REAL DLG IMPORT / EDIT / EXPORT

Start with START_STORY_MAKER.bat, then open DIALOGUES.

1. Choose or open a Story project folder. Choose your source override folder
   to list the real creatures and load your AREA to list its placed actors.
2. IMPORT .DLG opens that exact resource. The current DLG stays open when you
   select a different creature or map actor. No Hello/default dialogue is made.
3. Choose the matching baseline dialog.tlk in the top source settings, choose
   its encoding, then RESOLVE TEXT FROM TLK. Use UTF-8 for BG2 Enhanced Edition;
   use the appropriate Windows encoding for classic game TLKs.
   DLG does not contain the words themselves. Without the matching TLK, original
   strrefs remain editable and are shown as unresolved references, not blank
   replacement text. Import and unchanged/branch/script-only export need no TLK.
4. WHO TALKS chooses the creature or placed actor that will own this open DLG.
   ASSIGN OPEN DLG writes its reference into the staged CRE or ARE actor and
   the SAFE copy. It never changes the open DLG or invents a creature.
5. Select a LINE / STATE on the left. Edit its spoken text and entry conditions.
   For choices without a spoken line, choose NONE under WHO TALKS HERE.
6. Click ADD ANSWER once for each player choice. Set WHO ANSWERS to PLAYER,
   type the answer, then choose END or a destination state. Blank Next DLG
   means this same DLG. Several PLAYER rows are several selectable choices.
   Changes are kept when selecting another answer/line and included by Save
   and Export. No separate Update button is required.
7. For silent continuation, choose NONE as the answerer and set a next state.
   To let another NPC speak, choose its name in WHO ANSWERS. The editor uses
   that NPC's actually assigned DLG. OPEN LINKED DLG / LINE opens it explicitly
   after offering to save the current document. No generated fallback DLG is
   used when a linked resource is missing.
8. SAVE PROJECT preserves all editable data and original binary metadata.
   OPEN SAVED DIALOGUE restores it. EXPORT .DLG writes a real compiled DLG V1.0.
   SAVE TO SAFE writes it into the project's SAFE_INSTALL/override folder.

TEXT EXPORT / INSTALLATION
- Unchanged text keeps its original strref, including the original TLK voice
  sound reference. Editing words appends new text instead of replacing shared
  entries in the baseline TLK.
- When Export needs new strings, it also writes NAME_TEXT/dialog.tlk beside
  NAME.DLG. This matching TLK is required for those new strings. The status
  and export message give its exact location.
- In a Story project, successive exports reuse a compatible SAFE dialog.tlk
  and append text so another already exported DLG's strings are not replaced.
- For game use, the DLG goes in override; its matching dialog.tlk goes in the
  game's active language folder. Include the assigned CRE/ARE from SAFE_INSTALL
  if you changed ownership. The editor does not install into the live game.
- Exporting under a new filename updates self-links in that exported copy.
  External DLG links and the open document name remain unchanged. Import the
  renamed copy if you also want to assign that new resource name to a creature.

ENGINE BEHAVIOR
A DLG's owner supplies the NPC speaker. The DLG's transitions hold player
choices. Changing to another NPC uses that NPC's DLG through a linked state;
the binary format has no independent speaker/answerer character field for
every line. The controls reflect this actual format. PLAYER is an answer type,
not a fictitious persistent player CRE assignment.
The preview follows the branches you choose; game conditions/actions are
shown but not executed by the preview.
The first manually added line gets True() as its entry condition. Later lines
are branch-only until you supply entry conditions. No dialogue prose is added.
Deleting a line that another local branch still uses is blocked until that
branch is changed, instead of silently converting it to an exit.

PRESERVATION AND VALIDATION
- Preserves native DLG flags, journal references, scripts, external links,
  entry-trigger priority, shared transition behavior and unused native records.
- Untouched imports export byte-for-byte identically, including empty DLGs.
- 2,235 DLG resources from the supplied DIALOG.BIF passed exact binary round
  trips through import, saved JSON and export (32,157 states / 49,323 transitions).
- Supplied ACOLYTE2.DLG passed exact round trips and UI import/export checks.
- 31 regression checks passed, including actual Qt row switching, multiple
  choices, NONE speaker, NPC links, creature assignment, TLK preservation,
  renamed self-links, full Story builds and unsaved-close handling.
- No live BG2/BG2EE gameplay test was possible here. Script semantics and actor
  availability still depend on the actual game; structural validation does
  not execute your actions or conditions.
- The supplied NearInfinity.jar was inspected as a reference. Its graphical
  reader was not used as a passing validation gate in the headless test runtime.

Reference: https://gibberlings3.github.io/iesdp/file_formats/ie_formats/dlg_v1.htm
Developer regression command (pytest required):
  python -m pytest -q test_dialogue_editor_v106.py
Optional DLG_SAMPLE and DLG_BIF environment variables add external fixtures.
